*Analysis of coverage on mortality and heterogeneity in effect of coverage on mortality

cap log close

global path = "****"
local name= "2sls_tables"  
local date = "052920"
global logname = "$path/`name'_`date'.log"

clear
set more off
cd "$path"
log using "$logname", replace

use "$path/Data/penalty_sample.dta", clear

rename fpl_frac magi_fpl2015
keep if age_2017 < 65 & age_2017 >= 45
keep if notall16 == 1 


*Table: Main 2SLS Table
*Col 1: OLS
reg dead1718 covered1718, cl(tin)
eststo
estadd scalar nobs e(N)
summ `e(depvar)' if e(sample)&treatment==0
estadd scalar ymean=r(mean)*100
estimates save "$path/2sls_main_`date'.ster", replace

*Col 2: first stage
reg covered1718 treatment, cl(tin)
eststo
estadd scalar nobs e(N)
summ `e(depvar)' if e(sample)&treatment==0
estadd scalar ymean=r(mean)
estimates save "$path/2sls_main_`date'.ster", append

*Col 3: ITT
reg dead1718 treatment, cl(tin)
eststo
estadd scalar nobs e(N)
summ `e(depvar)' if e(sample)&treatment==0
estadd scalar ymean=r(mean)*100
estimates save "$path/2sls_main_`date'.ster", append

*col 4: IV
ivregress 2sls dead1718 (covered1718=treatment), cl(tin)
eststo
estadd scalar nobs e(N)
summ `e(depvar)' if e(sample)&treatment==0
estadd scalar ymean=r(mean)*100
estimates save "$path/2sls_main_`date'.ster", append
   

			   

*Table: 2sls Heterogeneity

estimates clear
eststo clear

*col 1: magi_fpl2015 <= 1.38
ivregress 2sls dead1718 (covered1718=treatment) if magi_fpl2015 <= 1.38, cl(tin)
eststo
estadd scalar nobs e(N)
summ `e(depvar)' if e(sample)&treatment==0
estadd scalar ymean=r(mean)*100
estimates save "$path/2sls_heterogeneity_`date'.ster", replace

*col 2: magi_fpl2015 > 1.38   
ivregress 2sls dead1718 (covered1718=treatment) if magi_fpl2015 > 1.38, cl(tin)
eststo
estadd scalar nobs e(N)
summ `e(depvar)' if e(sample)&treatment==0
estadd scalar ymean=r(mean)*100
estimates save "$path/2sls_heterogeneity_`date'.ster", append

*col 3: expansion states  
ivregress 2sls dead1718 (covered1718=treatment) if expansion == 1, cl(tin)
eststo
estadd scalar nobs e(N)
summ `e(depvar)' if e(sample)&treatment==0
estadd scalar ymean=r(mean)*100
estimates save "$path/2sls_heterogeneity_`date'.ster", append

*col 4: non-expansion states  
ivregress 2sls dead1718 (covered1718=treatment) if expansion == 0, cl(tin)
eststo
estadd scalar nobs e(N)
summ `e(depvar)' if e(sample)&treatment==0
estadd scalar ymean=r(mean)*100
estimates save "$path/2sls_heterogeneity_`date'.ster", append

*col 5: men
ivregress 2sls dead1718 (covered1718=treatment) if male == 1, cl(tin)
eststo
estadd scalar nobs e(N)
summ `e(depvar)' if e(sample)&treatment==0
estadd scalar ymean=r(mean)*100
estimates save "$path/2sls_heterogeneity_`date'.ster", append

*col 6: women
ivregress 2sls dead1718 (covered1718=treatment) if male == 0, cl(tin)
eststo
estadd scalar nobs e(N)
summ `e(depvar)' if e(sample)&treatment==0
estadd scalar ymean=r(mean)*100
estimates save "$path/2sls_heterogeneity_`date'.ster", append

*col 7: married
ivregress 2sls dead1718 (covered1718=treatment) if married == 1, cl(tin)
eststo
estadd scalar nobs e(N)
summ `e(depvar)' if e(sample)&treatment==0
estadd scalar ymean=r(mean)*100
estimates save "$path/2sls_heterogeneity_`date'.ster", append

*col 8: non-married
ivregress 2sls dead1718 (covered1718=treatment) if married == 0, cl(tin)
eststo
estadd scalar nobs e(N)
summ `e(depvar)' if e(sample)&treatment==0
estadd scalar ymean=r(mean)*100
estimates save "$path/2sls_heterogeneity_`date'.ster", append

log close

